<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>016_封装防抖方法</title>
</head>
<body>
  
</body>
<script>
  function debounce (fn, wait) {
    var timerId;
    wait = wait || 0;
    function helper () {
      var args = arguments
      if (timerId) {
        clearTimeout(timerId);
        timerId = null;
      }
      timerId = setTimeout(function (){
        fn.apply(this, args);
      }, wait);
    }
    return helper;
  }

  function notifyChange(event, num) {
    console.log('浏览器的窗口改变了1111', event, num);
  }
  var notifyChangeDebounce = debounce(notifyChange, 1000)
window.addEventListener('resize', function(event) {
  notifyChangeDebounce.call(this, event, '2')
});
// window.addEventListener('resize', function (event) { notifyChange(event, '1')}); // 如果不加防抖处理，可以使用这种方法传参
/*
* 怎么传递参数？
* 怎么传递event？
* es6?
*/
</script>
</html>